import { login } from '@/api/user'
import { delToken, getToken, setToken } from '@/utils/storage'

export default {
  namespaced: true,
  state () {
    return {
      token: getToken() || ''
    }
  },
  getters: {},
  mutations: {
    setToken (state, token) {
      state.token = token
      setToken(token)
    },
    delToken (state) {
      state.token = ''
      delToken()
    }
  },
  actions: {
    async login (context, obj) {
      const res = await login(obj)
      // console.log(res.data.token)
      context.commit('setToken', res.data.token)
    },
    test () {
      console.log(111)
    }
  }
}
